package com.design.pattern.behaviour.observer;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author hanyuanlai
 * @Date 2022/8/22
 */
public abstract class Subject {
    List<Observer> observers = new ArrayList<>();

    public void register(Observer observer) {
        observers.add(observer);
    }

    public void remove(Observer observer) {
        observers.remove(observer);
    }

    public void notity() {
        for (Observer observer : observers) {
            observer.update();
        }
    }
}
